package pers.karl;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * Copyright @ 2019 ds.Keytop.com.cn. All rights reserved.
 *
 * @Package: pers.karl
 * @Description: 生产消息
 * @Author: caoqiuliang
 * @Date: 2019年11月13日
 * @version: V1.0
 */
@RestController
@RequestMapping("producer")
public class ProducerController {

    @Autowired
    private AmqpTemplate amqpTemplate;

    @RequestMapping("push")
    public String push() {
        String routingKey = "bi.message.push";

        Map<String,Object> map = new HashMap<>();
        map.put("name", "张三");
        map.put("age", 18);
        map.put("deleted", true);
        map.put("money", 999.99);
        map.put("list", Arrays.asList("134",23));
        amqpTemplate.convertAndSend(routingKey, map);

        System.out.println("发送成功");
        return "success";
    }

}
